package adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;


import java.util.List;

import tangyaxin.www.saoerweima.R;

/**
 * Created by Administrator on 2016/7/7.
 */
public class ContactInfoAdapter extends BaseAdapter {
    private Context context;
    private List<String> data;

    public ContactInfoAdapter(Context context,List<String> data){
        this.context = context;
        this.data = data;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public String getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        CheckBox checkBox = null;
        if(convertView == null){
            convertView = View.inflate(context, R.layout.item_contact_info_item,null);
            checkBox = (CheckBox) convertView;
            convertView.setTag(checkBox);
        } else {
            checkBox = (CheckBox) convertView.getTag();
        }

        checkBox.setText(getItem(position));
        return convertView;
    }
}
